#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[40000],b[40000]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U'};
	int i,cnt=0,n,r;
	cin>>n>>r;
	cout<<n<<"=";
	while(n)
	{
		if(n%r<0)
		{
			a[cnt++]=b[n%r-r];
			n+=r;
		}
		else
		a[cnt++]=b[n%r];
		n/=r;
	}
	for(i=cnt-1;i>=0;i--)
	printf("%c",a[i]);
	printf("(base%d)",r);
    return 0;
}
